<template>
    <div>
        <!-- <header>
            <router-link to="/friendList">我邀请的好友 ></router-link>
        </header> -->
        <div class="cont">
            <div class="title">
                <img src="../../asset/icon/icon_league_left.png">
                <span>排队返利规则</span>
                <img src="../../asset/icon/icon_league_right.png">
            </div>
            <div
                class="text"
                v-html="contSource.rebate_rule"
            ></div>
            <div class="code">
                <div
                    id="qrcode"
                    ref="qrcode"
                ></div>
            </div>
        </div>
        <footer @click="$dialog.toast({ mes: '请点击右上角进行分享', timeout: 1000 });">
            <div>
                <img src="../../asset/icon/icon_wx.png">
                <p>微信</p>
            </div>
            <div>
                <img src="../../asset/icon/icon_wxpyq.png">
                <p>微信朋友圈</p>
            </div>
            <div>
                <img src="../../asset/icon/icon_qq.png">
                <p>QQ</p>
            </div>
            <div>
                <img src="../../asset/icon/icon_qqkongjian.png">
                <p>QQ空间</p>
            </div>
        </footer>
    </div>
</template>
<script>
import wxShare from '../../config/wxShare.js';
import QRCode from "qrcodejs2";
export default {
    name: "orderShare",
    data() {
        return {
            contSource: {}
        };
    },
    methods: {
        qrcode() {
            console.log();
            let goods_id = this.$route.query.goods_id,
                order_id = this.$route.query.order_id;
            let qrcode = new QRCode("qrcode", {
                width: 168,
                height: 168,
                text: location.href.split('#')[0] + '#/goods?goods_id=' + goods_id + '&order_id=' + order_id + '&type=goods&from=123'
                // text: 'http://wangzhuan.3todo.com/' + '?share_id=' + localStorage.getItem('userid') + '&form=123'
            });
        },
        // 方法
        infoData() {
            let params = {};
            this.$post("Sysconfig/getSysConfig", params)
                .then(res => {
                    if (res.code === 20000) {
                        this.contSource = res.data
                        this.qrcode()
                        this.map()
                    }
                })
                .catch(err => { });
        },
        map(index) {
            let params = {
                url: location.href.split('#')[0],
            };
            this.$post("Index/getWxConfig", params)
                .then(res => {
                    if (res.code === 20000) {
                        wxShare(res.data, res.content, this.WXShareSuccess)
                    }
                })
                .catch(err => { });
        },
        WXShareSuccess() {
            this.$dialog.toast({ mes: '分享成功', timeout: 1000 });
        }
    },
    beforeCreate() {
        document.querySelector("body").setAttribute("style", "background-color:#fff");
    },
    created() {
        console.log(this.global_);
        // 实例创建完成
        this.infoData();
    },
};
</script>
<style lang="less" scoped>
@import url("../../asset/css/orderShare");
// @import url("../../asset/css/friend");
</style>